Skip to content

Migrate simple try-with-resources use of AgentScope to ContextScope#11763

Open
mcculls wants to merge 1 commit into
masterfrom
mcculls/context-scope-migration-1
Open

Migrate simple try-with-resources use of AgentScope to ContextScope#11763
mcculls wants to merge 1 commit into
masterfrom
mcculls/context-scope-migration-1

Conversation

@mcculls

@mcculls mcculls commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Motivation

Reduce use of AgentScope in the codebase - first round of migration

Contributor Checklist

  • Format the title according to the contribution guidelines
  • Assign the type: and (comp: or inst:) labels in addition to any other useful labels
  • Avoid using close, fix, or any linking keywords when referencing an issue
    Use solves instead, and assign the PR milestone to the issue
  • Update the CODEOWNERS file on source file addition, migration, or deletion
  • Update public documentation with any new configuration flags or behaviors
  • Add your completed PR to the merge queue by commenting /merge. You can also:
    • Customize the commit message associated with the merge with /merge --commit-message "..."
    • Remove your PR from the merge queue with /merge -c
    • Skip all merge queue checks with /merge -f --reason "reason"; please use this judiciously, as some checks do not run at the PR-level (note: the PR still needs to be mergeable, this will only skip the pre-merge build)
    • Get more information in this doc

Jira ticket: [PROJ-IDENT]

@mcculls mcculls force-pushed the mcculls/context-scope-migration-1 branch from b881465 to cfdacad Compare June 29, 2026 10:48
@mcculls mcculls force-pushed the mcculls/context-scope-migration-1 branch from cfdacad to 7ababa2 Compare June 29, 2026 10:51
@pr-commenter

pr-commenter Bot commented Jun 29, 2026

Copy link
Copy Markdown

Debugger benchmarks

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
ci_job_date 1782730800 1782731146
end_time 2026-06-29T11:01:29 2026-06-29T11:07:12
git_branch master mcculls/context-scope-migration-1
git_commit_sha e292db6 7ababa2
start_time 2026-06-29T11:00:01 2026-06-29T11:05:47
See matching parameters
Baseline Candidate
ci_job_id 1812434691 1812434691
ci_pipeline_id 121565995 121565995
cpu_model Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
git_commit_date 1782730294 1782730294

Summary

Found 0 performance improvements and 0 performance regressions! Performance is the same for 9 metrics, 6 unstable metrics.

See unchanged results
scenario Δ mean agg_http_req_duration_min Δ mean agg_http_req_duration_p50 Δ mean agg_http_req_duration_p75 Δ mean agg_http_req_duration_p99 Δ mean throughput
scenario:noprobe unstable
[-32.037µs; +43.988µs] or [-10.761%; +14.776%]
unstable
[-61.297µs; +42.384µs] or [-17.049%; +11.789%]
unstable
[-75.263µs; +48.144µs] or [-19.825%; +12.681%]
unstable
[-127.181µs; +430.475µs] or [-11.066%; +37.455%]
same
scenario:basic same same same unstable
[-250.349µs; -18.678µs] or [-21.935%; -1.636%]
unstable
[-149.633op/s; +149.633op/s] or [-5.985%; +5.985%]
scenario:loop same unsure
[+1.729µs; +13.119µs] or [+0.019%; +0.146%]
same same same
Request duration reports for reports
gantt
    title reports - request duration [CI 0.99] : candidate=None, baseline=None
    dateFormat X
    axisFormat %s
section baseline
noprobe (359.528 µs) : 320, 399
.   : milestone, 360,
basic (294.424 µs) : 288, 301
.   : milestone, 294,
loop (8.987 ms) : 8982, 8991
.   : milestone, 8987,
section candidate
noprobe (350.072 µs) : 293, 407
.   : milestone, 350,
basic (295.807 µs) : 289, 303
.   : milestone, 296,
loop (8.994 ms) : 8988, 9000
.   : milestone, 8994,
Loading
  • baseline results
Scenario Request median duration [CI 0.99]
noprobe 359.528 µs [319.766 µs, 399.291 µs]
basic 294.424 µs [287.634 µs, 301.213 µs]
loop 8.987 ms [8.982 ms, 8.991 ms]
  • candidate results
Scenario Request median duration [CI 0.99]
noprobe 350.072 µs [292.857 µs, 407.286 µs]
basic 295.807 µs [288.786 µs, 302.828 µs]
loop 8.994 ms [8.988 ms, 9.0 ms]

@dd-octo-sts

dd-octo-sts Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

🟢 Java Benchmark SLOs — All performance SLOs passed

Suite Status
Startup 🟢 pass

SLO thresholds are defined here based on automatically generated metrics. A warning is raised when results are within 5% of the threshold.

PR vs. master results
Scenario Candidate master Δ (95% CI of mean)
startup:insecure-bank:iast:Agent 14.01 s 14.00 s [-0.7%; +0.9%] (no difference)
startup:insecure-bank:tracing:Agent 12.94 s 13.03 s [-1.4%; -0.0%] (maybe better)
startup:petclinic:appsec:Agent 16.93 s 16.71 s [+0.3%; +2.3%] (maybe worse)
startup:petclinic:iast:Agent 16.88 s 16.90 s [-0.9%; +0.6%] (no difference)
startup:petclinic:profiling:Agent 16.21 s 16.86 s [-8.2%; +0.4%] (no difference)
startup:petclinic:sca:Agent 16.87 s 16.68 s [+0.2%; +2.1%] (maybe worse)
startup:petclinic:tracing:Agent 16.15 s 15.55 s [-1.7%; +9.5%] (unstable)

Commit: 7ababa21 · CI Pipeline · Benchmarking Platform UI


Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion.

@pr-commenter

pr-commenter Bot commented Jun 29, 2026

Copy link
Copy Markdown

Kafka / producer-benchmark

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch master mcculls/context-scope-migration-1
git_commit_date 1782729950 1782730294
git_commit_sha e292db6 7ababa2
See matching parameters
Baseline Candidate
ci_job_date 1782731287 1782731287
ci_job_id 1812434688 1812434688
ci_pipeline_id 121565995 121565995
cpu_model Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
jdkVersion 11.0.25 11.0.25
jmhVersion 1.36 1.36
jvm /usr/lib/jvm/java-11-openjdk-amd64/bin/java /usr/lib/jvm/java-11-openjdk-amd64/bin/java
jvmArgs -Dfile.encoding=UTF-8 -Djava.io.tmpdir=/go/src/github.com/DataDog/apm-reliability/dd-trace-java/platform/src/producer-benchmark/build/tmp/jmh -Duser.country=US -Duser.language=en -Duser.variant -Dfile.encoding=UTF-8 -Djava.io.tmpdir=/go/src/github.com/DataDog/apm-reliability/dd-trace-java/platform/src/producer-benchmark/build/tmp/jmh -Duser.country=US -Duser.language=en -Duser.variant
vmName OpenJDK 64-Bit Server VM OpenJDK 64-Bit Server VM
vmVersion 11.0.25+9-post-Ubuntu-1ubuntu122.04 11.0.25+9-post-Ubuntu-1ubuntu122.04

Summary

Found 0 performance improvements and 0 performance regressions! Performance is the same for 3 metrics, 0 unstable metrics.

See unchanged results
scenario Δ mean throughput
scenario:not-instrumented/KafkaProduceBenchmark.benchProduce same
scenario:only-tracing-dsm-disabled-benchmarks/KafkaProduceBenchmark.benchProduce same
scenario:only-tracing-dsm-enabled-benchmarks/KafkaProduceBenchmark.benchProduce unsure
[-3604.850op/s; -55.521op/s] or [-2.511%; -0.039%]

@pr-commenter

pr-commenter Bot commented Jun 29, 2026

Copy link
Copy Markdown

Kafka / consumer-benchmark

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch master mcculls/context-scope-migration-1
git_commit_date 1782729950 1782730294
git_commit_sha e292db6 7ababa2
See matching parameters
Baseline Candidate
ci_job_date 1782731327 1782731327
ci_job_id 1812434689 1812434689
ci_pipeline_id 121565995 121565995
cpu_model Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
jdkVersion 11.0.25 11.0.25
jmhVersion 1.36 1.36
jvm /usr/lib/jvm/java-11-openjdk-amd64/bin/java /usr/lib/jvm/java-11-openjdk-amd64/bin/java
jvmArgs -Dfile.encoding=UTF-8 -Djava.io.tmpdir=/go/src/github.com/DataDog/apm-reliability/dd-trace-java/platform/src/consumer-benchmark/build/tmp/jmh -Duser.country=US -Duser.language=en -Duser.variant -Dfile.encoding=UTF-8 -Djava.io.tmpdir=/go/src/github.com/DataDog/apm-reliability/dd-trace-java/platform/src/consumer-benchmark/build/tmp/jmh -Duser.country=US -Duser.language=en -Duser.variant
vmName OpenJDK 64-Bit Server VM OpenJDK 64-Bit Server VM
vmVersion 11.0.25+9-post-Ubuntu-1ubuntu122.04 11.0.25+9-post-Ubuntu-1ubuntu122.04

Summary

Found 0 performance improvements and 0 performance regressions! Performance is the same for 3 metrics, 0 unstable metrics.

See unchanged results
scenario Δ mean throughput
scenario:not-instrumented/KafkaConsumerBenchmark.benchConsume same
scenario:only-tracing-dsm-disabled-benchmarks/KafkaConsumerBenchmark.benchConsume same
scenario:only-tracing-dsm-enabled-benchmarks/KafkaConsumerBenchmark.benchConsume same

@mcculls mcculls marked this pull request as ready for review June 29, 2026 12:05
@mcculls mcculls requested review from a team as code owners June 29, 2026 12:05
@mcculls mcculls requested review from PerfectSlayer, claponcet, jandro996, mhlidd, tylfin and vandonr and removed request for a team June 29, 2026 12:05

@datadog-datadog-prod-us1-2 datadog-datadog-prod-us1-2 Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Datadog Autotest: PASS

More details

Uniform mechanical refactor across 88 files: every try-with-resources variable declaration changes from AgentScope to ContextScope, which is a valid widening reference conversion because AgentScope extends ContextScope. No method calls on the scope variable are added or removed; all callers (activateSpan, activateManualSpan, continuation.activate()) continue to return AgentScope at runtime, so close() dispatches identically via virtual method invocation. Null-scope safety in Wrapper.java is preserved by the JLS try-with-resources spec.

Was this helpful? React 👍 or 👎

📊 Validated against 4 scenarios · Open Bits AI session

🤖 Datadog Autotest · Commit 7ababa2 · What is Autotest? · Any feedback? Reach out in #autotest

@jpbempel jpbempel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for debugger code

@daniel-mohedano daniel-mohedano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM wrt CiVis changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants